// const BDApi = require('BDApi');
// const OPPOApi = require('OPPOApi');
// const QQApi = require('QQApi');
// const TTApi = require('TTApi');
// const VIVOApi = require('VIVOApi');
// const WXApi = require('WXApi');
const ANDROIDApi = require('ANDROIDApi');
// const IOSApi = require('IOSApi');
const H5Api = require("H5Api");
const CocosAnalytics = require("CocosAnalytics");
var Adv_skd=require("./../Adv_skd")
let ADSdk = {
    // name: 'ADSdk',
    properties: {

    },

    // SDK 开/关声音统一调这里，方便管理
    toggleMusic() {
        console.log("ADSDK soundManager toggleMusicPro")
        // GameApp.soundManager.toggleMusicPro();
    },

    // SDK toast 统一调这里，方便管理
    showToast(str = "视频填充不足，请稍后再试~") {
        var UIManage = require("UIManage");
        UIManage.Instance.ShowToast(str);
    },
    // 方便统计
    // 0 banner
    // 1 video
    showADFail(id) {
        switch (id) {
            case 0:
                if (AppConst.ANALYTICS) {
                    CocosAnalytics.eventFail("showBannerFail");
                }
                break;
            case 1:
                if (AppConst.ANALYTICS) {
                    CocosAnalytics.eventFail("showVideoFail");
                }
                this.showToast();
                break;
        }
    },

    init() {

        // 关闭/开启调试
        cc.debug.setDisplayStats(AppConst.DEBUG);

        this.sdkData = {
            share: { title: "这也太难了吧~", imageUrl: AppConst.SHAREIMAGEURL, desc: "" },
            ad: AppConst.SDKCONFIG
        };
        switch (AppConst.CHANNEL) {
            case AppConst.channel.ANDROID:
                ANDROIDApi.init(this.sdkData, this);
                break;
            case AppConst.channel.H5:
                H5Api.init(this.sdkData, this);
                break;
            default:
                break;
        }
    },

    login(cb) {

        switch (AppConst.CHANNEL) {
            case AppConst.channel.QQMiniGame:
            case AppConst.channel.WXMiniGame:
            case AppConst.channel.VIVOMiniGame:
            case AppConst.channel.OPPOMiniGame:
            case AppConst.channel.BDMiniGame:
            case AppConst.channel.TTMiniGame:
                break;
            case AppConst.channel.ANDROID:
                ANDROIDApi.login(cb);
                break;
            case AppConst.channel.IOS:
            case AppConst.channel.H5:
                break;
            default:
                break;
        }
    },

    showBanner(adUnitId = this.sdkData.ad.bannerId) {

        switch (AppConst.CHANNEL) {
            case AppConst.channel.ANDROID:
                ANDROIDApi.showBanner(adUnitId);
                break;
            case AppConst.channel.H5:
                H5Api.showBanner(adUnitId);
                break;
            default:
                break;
        }
    },

    hideBanner() {

        switch (AppConst.CHANNEL) {

            case AppConst.channel.ANDROID:
                ANDROIDApi.hideBanner();
                break;
            case AppConst.channel.H5:
                H5Api.hideBanner();
                break;
            default:
                break;
        }
    },

    showVideo(adUnitId = this.sdkData.ad.videoId, cb) {

        Adv_skd.default.instance.showVideo(()=>{
            cb(1)
        },()=>{
            cb
        })

        // switch (AppConst.CHANNEL) {
        //     case AppConst.channel.ANDROID:
        //         ANDROIDApi.showVideo(adUnitId, cb);
        //         break;
        //     case AppConst.channel.H5:
        //         H5Api.showVideo(adUnitId, cb);
        //         break;
        //     default:
        //         break;
        // }
    },


    // --------------------以下功能只支持原生---------------------
    pay(payId, _GameUI) {
        if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.pay(payId, _GameUI);
        } else if (AppConst.CHANNEL == AppConst.channel.IOS) {
            IOSApi.pay(payId, _GameUI);
        } else {
            console.log(AppConst.CHANNEL + " 无此API");
        }
    },

    moreGame() {
        if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.moreGame();
        } else if (AppConst.CHANNEL == AppConst.channel.IOS) {
            IOSApi.moreGame();
        } else {
            console.log(AppConst.CHANNEL + " 无此API");
        }
    },

    about() {
        if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.about();
        } else if (AppConst.CHANNEL == AppConst.channel.IOS) {
            IOSApi.about();
        } else {
            console.log(AppConst.CHANNEL + " 无此API");
        }
    },

    exitGame() {
        if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.exitGame();
        } else if (AppConst.CHANNEL == AppConst.channel.IOS) {
            IOSApi.exitGame();
        } else {
            console.log(AppConst.CHANNEL + " 无此API");
        }
    },

    isOpenMusic() {
        if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.isOpenMusic();
        } else if (AppConst.CHANNEL == AppConst.channel.IOS) {
            IOSApi.isOpenMusic();
        } else {
            console.log(AppConst.CHANNEL + " 无此API");
        }
    },


    showInsertAd(posId) {
        if (AppConst.CHANNEL == AppConst.channel.VIVOMiniGame) {
            VIVOApi.showInsertAd(posId);
        } else if (AppConst.CHANNEL == AppConst.channel.OPPOMiniGame) {
            OPPOApi.showInsertAd(posId);
        } else if (AppConst.CHANNEL == AppConst.channel.QQMiniGame) {
            QQApi.showInsertAd(posId);
        } else if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.showInsertAd(posId);
        } else {
            console.log(AppConst.CHANNEL + " 无此API");
        }
    },

    hideInsertAd(posId) {
        if (AppConst.CHANNEL == AppConst.channel.ANDROID) {
            ANDROIDApi.hideInsertAd(posId);
        }
    },




};
module.exports = ADSdk;